﻿using System;

namespace Assets.Script.Data.EnemyData
{
    /// <summary>
    /// 怪物基础信息
    /// </summary>
    public class EnemyData
    {
        public BaseData MaxHp { get; set; } = new BaseData();
        /// <summary>
        /// 移动速度
        /// </summary>
        public BaseData MoveSpeed { get; set; } = new BaseData();
        public BaseData Damage { get; set; } = new BaseData();
        /// <summary>
        /// 近战攻击距离
        /// </summary>
        public BaseData MeleeAttackDistance { get; set; } = new BaseData();
        /// <summary>
        /// 远程攻击距离
        /// </summary>
        public BaseData RangedAttackDistance { get; set; } = new BaseData();

        public BulletData BulletData { get; set; } = new BulletData();
        public float autoDieTime;
        public string perfabPath;
        public string enemyAIClassName;



        public EnemyData() {
        
        
        }

        public EnemyData(EnemyDataStuct data)
        {
            MaxHp = new BaseData(data.maxHp);
            MoveSpeed = new BaseData(data.moveSpeed);
            Damage = new BaseData(data.damage);
            MeleeAttackDistance = new BaseData(data.meleeAttackDistance);
            RangedAttackDistance = new BaseData(data.rangedAttackDistance);

            BulletData.Atk = new BaseData(data.atk);
            BulletData.BulletScale = new BaseData(data.bulletScale);
            BulletData.BulletLifeTime = new BaseData(data.bulletLifeTime);
            BulletData.BulletSpeed = new BaseData(data.bulletSpeed);
            BulletData.IsThrough = data.isThrough;

            autoDieTime = data.autoDieTime;
            perfabPath = data.perfabPath;
            enemyAIClassName = data.enemyAIClassName;
        
        }


        public EnemyData Plus(EnemyData data2)
        {
        
            MoveSpeed += data2.MoveSpeed;
            MaxHp += data2.MaxHp;
            Damage += data2.Damage;
            RangedAttackDistance += data2.RangedAttackDistance;
            MeleeAttackDistance += data2.MeleeAttackDistance;
            return this;
        }

        public EnemyData Minus(EnemyData data2)
        {
        
            MoveSpeed -= data2.MoveSpeed;
            MaxHp -= data2.MaxHp;
            Damage -= data2.Damage;
            RangedAttackDistance -= data2.RangedAttackDistance;
            MeleeAttackDistance -= data2.MeleeAttackDistance;
            return this;
        }

        [Serializable]
        public struct EnemyDataStuct
        {
            public float maxHp;
            public float moveSpeed;
            public float damage;
            public float meleeAttackDistance;
            public float rangedAttackDistance;

            public float atk;
            public float bulletScale;
            public float bulletLifeTime;
            public float bulletSpeed;
            public bool isThrough;

            public float autoDieTime;
            public string perfabPath;
            public string enemyAIClassName;


            public override bool Equals(object obj)
            {
                if (obj.GetType()!=typeof(EnemyDataStuct))
                {
                    return false;
                }
                EnemyDataStuct other = (EnemyDataStuct)obj;

                if (
                    maxHp!= other.maxHp||
                    moveSpeed != other.moveSpeed ||
                    damage != other.damage ||
                    meleeAttackDistance != other.meleeAttackDistance ||
                    rangedAttackDistance != other.rangedAttackDistance ||
                    atk != other.atk ||
                    bulletScale != other.bulletScale ||
                    bulletLifeTime != other.bulletLifeTime ||
                    bulletSpeed != other.bulletSpeed ||
                    isThrough != other.isThrough ||
                    autoDieTime != other.autoDieTime ||
                    perfabPath != other.perfabPath||
                    enemyAIClassName != other.enemyAIClassName
                    )
                {
                    return false;
                }
                return true;
            }

        }


    }

}